home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / sgml / unix / sgmlh / sgmlapi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-03  |  8.9 KB  |  139 lines

  1. /******************************************************************************/
  2. /* SGMLAPI.H: Codes for communication between a text processor (TP)
  3.               and SGML parser services.
  4. */
  5. /******************************************************************************/
  6. /* Return codes from SGMLNEXT.
  7. */
  8. #define TPPCDATA  1           /* Parsed character data found. */
  9. #define TPEOD     2           /* End of document. */
  10. #define TPETAG    3           /* End-tag. */
  11. #define TPPI      4           /* Processing instruction. */
  12. #define TPPIENT   5           /* Processing instruction entity. */
  13. #define TPRE      6           /* Significant record end. */
  14. #define TPSTAG    7           /* Start-tag. */
  15. #define TPCDATA   8           /* Declared character data found. */
  16. #define TPNDATA   9           /* Non-SGML data entity reference. */
  17. #define TPSDATA  10           /* System data entity reference. */
  18. #define TPNSGML  11           /* Non-SGML character reference. */
  19. /* The following are for housekeeping only; not supported for users. */
  20. #define TPMV     12           /* Markup validator information. */
  21. #define TPSDTD   13           /* Document type definition started. */
  22. #define TPEDTD   14           /* Document type definition ended. */
  23. /******************************************************************************/
  24. /* astatus: Attribute specification status codes set by ALNEXT.
  25. */
  26. #define TPAOK     0           /* Specified value had no errors. */
  27. #define TPAIMPLY  1           /* Impliable attribute not specified. */
  28. #define TPANOREQ  2           /* Required attribute not specified. */
  29. #define TPAERROR  3           /* Specified value had syntax error. */
  30. #define TPAINVAL  4           /* Specified value had value error. */
  31. /******************************************************************************/
  32. /* atype: Attribute type codes set by ALNEXT.
  33. */
  34. #define TPACDATA  0           /* Value is (possibly empty) character string. */
  35. #define TPATOKEN  1           /* Value is a single token. */
  36. #define TPALIST   2           /* Value is a list of one or more tokens. */
  37. /******************************************************************************/
  38. /* adata: Attribute codes set by ALNEXT when additional data is present.
  39. */
  40. #define TPANONE   0           /* No additional data for this attribute. */
  41. #define TPANOTE   1           /* Data content notation: system ID. */
  42. #define TPAENTIT  2           /* External entity: system ID, dcn, att list. */
  43. #define TPAIDREF  3           /* ID reference: valid/invalid.*/
  44. /******************************************************************************/
  45. /* Internal/external entity types for detype member of rcbde structure. */
  46. #define TPICDATA  1           /* Internal character data entity. */
  47. #define TPISDATA  2           /* Internal specific character data entity. */
  48. #define TPECDATA  3           /* External character data entity. */
  49. #define TPENDATA  4           /* Non-SGML data entity. */
  50. #define TPESDATA  5           /* External specific character data entity. */
  51. #define TPESUB    6           /* SGML subdocument entity (NOT SUPPORTED). */
  52. /******************************************************************************/
  53. /* Public variables allocated by SGMLAPI.C for use by a text processor (TP).  */
  54. /*       THESE ARE READ-ONLY!!!!!  MODIFICATIONS CAN CAUSE GREAT GRIEF!!!!!   */
  55. /******************************************************************************/
  56. #define CA (*(te.pca))        /* Active current att rcb: tag/link or data.    */
  57. /******************************************************************************/
  58. struct rcbca {                /* RCB for current attribute information. */
  59.      char    *aname;          /* Current attribute name. */
  60.      unsigned anamelen;       /* Length of current attribute name. */
  61.      char    *aval;           /* Current attribute value. */
  62.      unsigned avallen;        /* Length of attribute value. */
  63.      unsigned astatus;        /* Attribute status: implied, default, etc. */
  64.      unsigned atype;          /* Attribute type: string, token, or list. */
  65.      unsigned adata;          /* Attribute data: none, dcn, entity, ID ref. */
  66.      unsigned aconref;        /* Explicit content reference? 1=yes 0=no. */
  67.      char    *token;          /* Current token in tokenized value (no EOS). */
  68.      unsigned tokenlen;       /* Length of current token in tokenized value. */
  69.      unsigned idrstat;        /* ID reference status: 1=valid; 0=undefined. */
  70.      char    *dcnid;          /* Notation attribute system identifier. */
  71.      unsigned dcnidlen;       /* Length of notation identifier. */
  72.      /* The following are for housekeeping only; not supported for users. */
  73.      char     aflags;         /* Added attribute info (e.g.: defaulted?) */
  74.      unsigned aln;            /* Next attribute list member to process. */
  75.      unsigned avn;            /* Offset of next att value token to process. */
  76.      unsigned tn;             /* Number of next value token to process. */
  77.      unsigned entityn;        /* Current number of AENTITY(S) in att list.*/
  78.      unsigned idrn;           /* Current number of IDs referenced in att list.*/
  79. };
  80. struct rcbte {                /* RCB for calls to SGMLAPI. */
  81.      int passes;              /* Number of passes requested. */
  82.      int pass;                /* Current pass. */
  83.      unsigned datalen;        /* Length of returned data. */
  84.      char *data;              /* Returned data: data, GI, PI, etc. */
  85.      char nonsgml;            /* Actual (unshifted) non-SGML character. */
  86.      unsigned alcnt;          /* Number of attributes in list; 0=no list. */
  87.      struct rcbca *pca;       /* Active rcbca: tag/link or data entity. */
  88.      struct rcbca ca;         /* Return control block: current tag attribute.*/
  89.      void *gidata;            /* User data for GI. */
  90. #ifdef V2
  91.      unsigned format;         /* Default format type for element. */
  92. #endif
  93. };
  94. struct rcbde {                /* RCB for current data entity description. */
  95.      char    *ename;          /* Current entity name. */
  96.      unsigned enamelen;       /* Length of current entity name. */
  97.      unsigned detype;         /* Data entity type: int C/S; ext C/S/N/SUBDOC. */
  98.      char    *detxt;          /* Internal text or external system identifier. */
  99.      unsigned detxtlen;       /* Length of data entity text or system ID. */
  100.      char    *dcnnm;          /* Data content notation name. */
  101.      unsigned dcnnmlen;       /* Length of notation name. */
  102.      char    *dcnid;          /* Data content notation system identifier. */
  103.      unsigned dcnidlen;       /* Length of notation identifier. */
  104.      unsigned alcnt;          /* Number of attributes in list; 0=no list. */
  105.      struct rcbca ca;         /* Return control block: current data attribute.*/
  106. };
  107. /******************************************************************************/
  108. extern struct rcbde de;       /* RCB for current data entity information. */
  109. extern struct rcbte te;       /* RCB for calls to SGMLAPI. */
  110. extern char sgmlomsg[];       /* Text for invalid option error message. */
  111. /******************************************************************************/
  112. /* SGMLAPI function library
  113. */
  114. /******************************************************************************/
  115. char *sgmlopt(char *);        /* Process a supported parser option argument. */
  116. void sgmloset(void);          /* Initialize for SGML option processing. */
  117. void sgmlset(void);           /* Initialize the parser for the run. */
  118. int docent(unsigned char *);  /* Initialize the SGML document entity. */
  119. int sgmlpset(void);           /* Initialize pass; open document entity. */
  120. int sgmlnext(void);           /* Get next SGML event: data, tag, etc. */
  121. unsigned int sgmlend(void);   /* Terminate SGML processing. */
  122. int alnext(void);             /* Process next attribute in list. */
  123. void idrnext(void);           /* Process IDREF or IDREFS token in value. */
  124. /******************************************************************************/
  125. /*lint +fvr                      Returned value may be ignored. */
  126. int avnext(void);             /* Process next token in attribute value. */
  127. int getent(unsigned, char *); /* Build data entity rcbde with entity name. */
  128. int giset(char *,void *,void *); /* Save user data for an element. */
  129. /*lint -fvr                      Restore normal LINT processing. */
  130. /******************************************************************************/
  131. /* Environment and compiler function libraries
  132. */
  133. /******************************************************************************/
  134. #include <stdio.h>            /* Stream I/O functions. */
  135. #include <stdlib.h>           /* Common types, variables, and functions. */
  136. #include <string.h>           /* Memory and string functions. */
  137. void location(int);           /* SGMLMSG: print file location in message. */
  138. /******************************************************************************/
  139.